const express = require("express")
const app = express()

app.use((req, resp, next) => {
    console.log("请求...")
    next()
})

app.get("/cars", (req, res) => {
    const cars = [
        {id: "001", name: "奔驰", price: 199},
        {id: "002", name: "马自达", price: 109},
        {id: "003", name: "捷达", price: 120}
    ]
    res.send(cars)
})

app.get("/students", (req, res) => {
    const students = [
        {id: "001", name: "tom", age: 18},
        {id: "002", name: "jerry", age: 19},
        {id: "003", name: "tony", price: 20}
    ]
    res.send(students)
})

app.listen(5000, err => {
  if (!err) console.log("Start...")
})